<template>
  <div>
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="false"
      label-width="100px"
    >
      <!-- <el-form-item label="内购通信录表ID" prop="internalPurchaseContactId">
        <el-input
          v-model="queryParams.internalPurchaseContactId"
          placeholder="请输入内购通信录表ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="模板ID" prop="templateId">
        <el-input
          v-model="queryParams.templateId"
          placeholder="请输入模板ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="线上订单号" prop="onlineNumber">
        <el-input
          v-model="queryParams.onlineNumber"
          placeholder="请输入线上订单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="子订单编号" prop="subOrderNumber">
        <el-input
          v-model="queryParams.subOrderNumber"
          placeholder="请输入子订单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button
          :icon="!isOpen ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"
          size="mini"
          @click="shouqi"
          >展开/收起</el-button
        >
      </el-form-item>

      <div v-if="isOpen">
        <el-form-item label="买家帐号" prop="buyerAccount">
          <el-input
            v-model="queryParams.buyerAccount"
            placeholder="请输入买家帐号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="支付单号" prop="paymentOrderNumber">
          <el-input
            v-model="queryParams.paymentOrderNumber"
            placeholder="请输入支付单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="付款方式" prop="paymentMethod">
          <el-input
            v-model="queryParams.paymentMethod"
            placeholder="请输入付款方式"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="运费" prop="freight">
          <el-input
            v-model="queryParams.freight"
            placeholder="请输入运费"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="应付金额" prop="payableAmount">
          <el-input
            v-model="queryParams.payableAmount"
            placeholder="请输入应付金额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="固话" prop="fixedLine">
          <el-input
            v-model="queryParams.fixedLine"
            placeholder="请输入固话"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="邮编" prop="zipCode">
          <el-input
            v-model="queryParams.zipCode"
            placeholder="请输入邮编"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品编码" prop="productCode">
          <el-input
            v-model="queryParams.productCode"
            placeholder="请输入商品编码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品数量" prop="productNum">
          <el-input
            v-model="queryParams.productNum"
            placeholder="请输入商品数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品名称" prop="productName">
          <el-input
            v-model="queryParams.productName"
            placeholder="请输入商品名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品单价" prop="productPricing">
          <el-input
            v-model="queryParams.productPricing"
            placeholder="请输入商品单价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品成本" prop="productCost">
          <el-input
            v-model="queryParams.productCost"
            placeholder="请输入商品成本"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="结算金额" prop="productSettlment">
          <el-input
            v-model="queryParams.productSettlment"
            placeholder="请输入结算金额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="生产批次" prop="productBatch">
          <el-input
            v-model="queryParams.productBatch"
            placeholder="请输入生产批次"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="生产日期" prop="manufactureDate">
          <el-date-picker
            clearable
            v-model="queryParams.manufactureDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择生产日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="快递公司" prop="expressCompany">
          <el-input
            v-model="queryParams.expressCompany"
            placeholder="请输入快递公司"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="快递单号" prop="expressNumber">
          <el-input
            v-model="queryParams.expressNumber"
            placeholder="请输入快递单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="发货时间" prop="deliveryTime">
          <el-date-picker
            clearable
            v-model="queryParams.deliveryTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择发货时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="业务员" prop="salesman">
          <el-input
            v-model="queryParams.salesman"
            placeholder="请输入业务员"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="便签|线下备注" prop="offlineNotes">
          <el-input
            v-model="queryParams.offlineNotes"
            placeholder="请输入便签|线下备注"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <!-- <el-form-item label="逻辑删除;0=未删除；1=已删除" prop="isDelete">
        <el-input
          v-model="queryParams.isDelete"
          placeholder="请输入逻辑删除;0=未删除；1=已删除"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
        <!-- <el-form-item
        label="退货联系方式-internal_purchase_contact表的id"
        prop="returnContactId"
      >
        <el-input
          v-model="queryParams.returnContactId"
          placeholder="请输入退货联系方式-internal_purchase_contact表的id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
        <el-form-item label="退货取件码" prop="returnExpressPickupCode">
          <el-input
            v-model="queryParams.returnExpressPickupCode"
            placeholder="请输入退货取件码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="退货订单号" prop="returnExpressNumber">
          <el-input
            v-model="queryParams.returnExpressNumber"
            placeholder="请输入退货订单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="退货时间" prop="returnDate">
          <el-date-picker
            clearable
            v-model="queryParams.returnDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择退货时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="流程模板ID" prop="flowModelId">
          <el-input
            v-model="queryParams.flowModelId"
            placeholder="请输入流程模板ID"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="待退货数量" prop="toReturnNum">
          <el-input
            v-model="queryParams.toReturnNum"
            placeholder="请输入待退货数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="退货中数量" prop="returningNum">
          <el-input
            v-model="queryParams.returningNum"
            placeholder="请输入退货中数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="已退货数量" prop="returnedNum">
          <el-input
            v-model="queryParams.returnedNum"
            placeholder="请输入已退货数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="申请时间" prop="applyDate">
          <el-date-picker
            clearable
            v-model="queryParams.applyDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择申请时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="签收时间" prop="signedTime">
          <el-date-picker
            clearable
            v-model="queryParams.signedTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择签收时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="电话" prop="phone">
          <el-input
            v-model="queryParams.phone"
            placeholder="请输入电话"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="收件人" prop="recipient">
          <el-input
            v-model="queryParams.recipient"
            placeholder="请输入收件人"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="地址" prop="address">
          <el-input
            v-model="queryParams.address"
            placeholder="请输入地址"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="收货省份" prop="receiverState">
          <el-input
            v-model="queryParams.receiverState"
            placeholder="请输入收货省份"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="收货市" prop="receiverCity">
          <el-input
            v-model="queryParams.receiverCity"
            placeholder="请输入收货市"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="收货区/街道" prop="receiverDistrict">
          <el-input
            v-model="queryParams.receiverDistrict"
            placeholder="请输入收货区/街道"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="聚水潭-内部订单号" prop="oid">
          <el-input
            v-model="queryParams.oid"
            placeholder="请输入聚水潭-内部订单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="原始地址" prop="fullAddress">
          <el-input
            v-model="queryParams.fullAddress"
            placeholder="请输入原始地址"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="详细地址" prop="detailAddress">
          <el-input
            v-model="queryParams.detailAddress"
            placeholder="请输入详细地址"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <!-- <el-form-item label="${comment}" prop="innerApplyReason">
        <el-input
          v-model="queryParams.innerApplyReason"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="bindingSoid">
        <el-input
          v-model="queryParams.bindingSoid"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="isReturnRemark">
        <el-input
          v-model="queryParams.isReturnRemark"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
        <el-form-item label="支付截图" prop="paymentUrl">
          <el-input
            v-model="queryParams.paymentUrl"
            placeholder="请输入支付截图"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <!-- <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item> -->
      </div>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['product:apply:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['product:apply:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['product:apply:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['product:apply:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          size="mini"
          @click="handleApply"
          v-hasPermi="['product:internalOrder:submitApplyByApplyIdList']"
          >提交商品订单</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      :data="applyList"
      @selection-change="handleSelectionChange"
      @row-dblclick="t"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column
        fixed
        width="80"
        label="申请ID"
        align="center"
        prop="id"
      />
      <!-- <el-table-column
        label="内购通信录表ID"
        align="center"
        prop="internalPurchaseContactId"
      />
      <el-table-column
        width="120"
        label="模板ID"
        align="center"
        prop="templateId"
      /> -->
      <el-table-column
        fixed
        width="80"
        label="内部订单号"
        align="center"
        prop="oid"
      />
      <el-table-column
        fixed
        width="80"
        label="原始单ID"
        align="center"
        prop="origApplyID"
      />

      <el-table-column
        fixed
        width="120"
        label="申请人ID"
        align="center"
        prop="buyerAccount"
      />
      <el-table-column
        fixed
        width="100"
        label="申请状态"
        align="center"
        prop="applyStatus"
      >
        <template slot-scope="scope">
          <div>
            {{ scope.row.applyStatus | state2 }}
          </div>
        </template>
      </el-table-column>

      <el-table-column
        fixed
        width="100"
        label="货号"
        align="center"
        prop="productNo"
      />
      <el-table-column
        fixed
        width="100"
        label="颜色"
        align="center"
        prop="colorProperty"
      />
      <el-table-column
        fixed
        width="80"
        label="尺码"
        align="center"
        prop="productSize"
      />

      <el-table-column
        fixed
        label="款式主图"
        align="center"
        prop="styleMainImage"
        width="100"
      >
        <template slot-scope="scope">
          <image-preview
            :src="scope.row.styleMainImage"
            :width="50"
            :height="50"
          />
        </template>
      </el-table-column>
      <el-table-column
        width="130"
        label="商品编码"
        align="center"
        prop="productCode"
      />
      <el-table-column
        width="120"
        label="商品数量"
        align="center"
        prop="productNum"
      />
      <el-table-column
        width="120"
        label="商品单价"
        align="center"
        prop="productPricing"
      />
      <el-table-column
        width="120"
        label="快递公司"
        align="center"
        prop="expressCompany"
      />
      <el-table-column
        width="120"
        label="快递单号"
        align="center"
        prop="expressNumber"
      />
      <el-table-column
        label="发货时间"
        align="center"
        prop="deliveryTime"
        width="120"
      >
        <!-- <template slot-scope="scope">
          <span>{{ parseTime(scope.row.deliveryTime, "{y}-{m}-{d}") }}</span>
        </template> -->
      </el-table-column>
      <!-- <el-table-column
        label="申请时间"
        align="center"
        prop="applyDate"
        width="120"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.applyDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="签收时间"
        align="center"
        prop="signedTime"
        width="120"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.signedTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column> -->
      <el-table-column width="120" label="电话" align="center" prop="phone" />
      <el-table-column
        width="120"
        label="收件人"
        align="center"
        prop="recipient"
      />

      <el-table-column
        width="120"
        label="收货省份"
        align="center"
        prop="receiverState"
      />
      <el-table-column
        width="120"
        label="收货市"
        align="center"
        prop="receiverCity"
      />
      <el-table-column
        width="120"
        label="收货区/街道"
        align="center"
        prop="receiverDistrict"
      />
      <el-table-column width="120" label="地址" align="center" prop="address" />
      <!-- <el-table-column
        width="130"
        label="聚水潭-内部订单号"
        align="center"
        prop="oid"
      />
      <el-table-column
        width="120"
        label="原始地址"
        align="center"
        prop="fullAddress"
      /> 
      <el-table-column
        width="120"
        label="详细地址"
        align="center"
        prop="detailAddress"
      />
      <el-table-column
        width="120"
        label="商品名称"
        align="center"
        prop="productName"
      />-->

      <!-- <el-table-column
        width="120"
        label="商品成本"
        align="center"
        prop="productCost"
      />
      <el-table-column
        label="结算金额"
        align="center"
        prop="productSettlment"
      /> -->
      <el-table-column
        width="120"
        label="卖家备注"
        align="center"
        prop="remark"
      />
      <el-table-column
        width="120"
        label="线上订单号"
        align="center"
        prop="onlineNumber"
      />
      <el-table-column
        width="120"
        label="子订单编号"
        align="center"
        prop="subOrderNumber"
      />

      <el-table-column
        label="支付单号"
        align="center"
        prop="paymentOrderNumber"
      />
      <el-table-column
        width="120"
        label="付款方式"
        align="center"
        prop="paymentMethod"
      />
      <el-table-column width="120" label="售后单" align="center" prop="asid" />
      <el-table-column
        width="120"
        label="售后分类"
        align="center"
        prop="afterSaleType"
      >
        <template slot-scope="scope">
          <div>
            {{ scope.row.afterSaleType | state1 }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="换货理由"
        align="center"
        prop="exchangeReason"
      />
      <el-table-column
        width="120"
        label="退回快递公司"
        align="center"
        prop="returnExpressCompany"
      />
      <el-table-column
        width="120"
        label="退回快递号"
        align="center"
        prop="returnExpressNumber"
      />
      <el-table-column
        width="120"
        label="正在退回数量"
        align="center"
        prop="returningNum"
      />
      <el-table-column
        width="120"
        label="已退回数量"
        align="center"
        prop="returnedNum"
      />
      <el-table-column
        width="120"
        label="退货时间"
        align="center"
        prop="returnDate"
      />
      <!-- <el-table-column width="120" label="运费" align="center" prop="freight" />
      <el-table-column
        width="120"
        label="应付金额"
        align="center"
        prop="payableAmount"
      />
      <el-table-column
        label="支付截图"
        align="center"
        prop="paymentUrl"
        width="100"
      >
        <template slot-scope="scope">
          <image-preview :src="scope.row.paymentUrl" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="固话"
        align="center"
        prop="fixedLine"
      />
      <el-table-column width="120" label="邮编" align="center" prop="zipCode" />
      <el-table-column
        width="120"
        label="生产批次"
        align="center"
        prop="productBatch"
      />
      <el-table-column
        width="120"
        label="生产日期"
        align="center"
        prop="manufactureDate"
      >
      </el-table-column>

      <el-table-column
        width="120"
        label="业务员"
        align="center"
        prop="salesman"
      />
      <el-table-column
        width="120"
        label="便签|线下备注"
        align="center"
        prop="offlineNotes"
      />

      
      <el-table-column
        width="120"
        label="退货取件码"
        align="center"
        prop="returnExpressPickupCode"
      />
      <el-table-column
        width="120"
        label="退货订单号"
        align="center"
        prop="returnExpressNumber"
      />
      <el-table-column
        label="退货时间"
        align="center"
        prop="returnDate"
        width="120"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.returnDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="流程模板ID"
        align="center"
        prop="flowModelId"
      />
      <el-table-column
        width="120"
        label="待退货数量"
        align="center"
        prop="toReturnNum"
      />
      <el-table-column
        width="120"
        label="退货中数量"
        align="center"
        prop="returningNum"
      />
      <el-table-column
        width="120"
        label="已退货数量"
        align="center"
        prop="returnedNum"
      /> -->
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改内购申请记录对话框 -->
    <!-- <el-dialog :title="title" :visible.sync="open" width="90%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-col span="8">
          <el-form-item label="内购通信录表ID" prop="internalPurchaseContactId">
            <el-input
              v-model="form.internalPurchaseContactId"
              placeholder="请输入内购通信录表ID"
            />
          </el-form-item>
          <el-form-item label="模板ID" prop="templateId">
            <el-input v-model="form.templateId" placeholder="请输入模板ID" />
          </el-form-item>
          <el-form-item label="卖家备注" prop="remark">
            <el-input v-model="form.remark" placeholder="请输入卖家备注" />
          </el-form-item>
          <el-form-item label="线上订单号" prop="onlineNumber">
            <el-input
              v-model="form.onlineNumber"
              placeholder="请输入线上订单号"
            />
          </el-form-item>
          <el-form-item label="子订单编号" prop="subOrderNumber">
            <el-input
              v-model="form.subOrderNumber"
              placeholder="请输入子订单编号"
            />
          </el-form-item>
          <el-form-item label="买家帐号" prop="buyerAccount">
            <el-input
              v-model="form.buyerAccount"
              placeholder="请输入买家帐号"
            />
          </el-form-item>
          <el-form-item label="支付单号" prop="paymentOrderNumber">
            <el-input
              v-model="form.paymentOrderNumber"
              placeholder="请输入支付单号"
            />
          </el-form-item>
          <el-form-item label="付款方式" prop="paymentMethod">
            <el-input
              v-model="form.paymentMethod"
              placeholder="请输入付款方式"
            />
          </el-form-item>
          <el-form-item label="运费" prop="freight">
            <el-input v-model="form.freight" placeholder="请输入运费" />
          </el-form-item>
          <el-form-item label="应付金额" prop="payableAmount">
            <el-input
              v-model="form.payableAmount"
              placeholder="请输入应付金额"
            />
          </el-form-item>
          <el-form-item label="固话" prop="fixedLine">
            <el-input v-model="form.fixedLine" placeholder="请输入固话" />
          </el-form-item>
          <el-form-item label="邮编" prop="zipCode">
            <el-input v-model="form.zipCode" placeholder="请输入邮编" />
          </el-form-item>
          <el-form-item label="款式主图" prop="styleMainImage">
            <image-upload v-model="form.styleMainImage" />
          </el-form-item> </el-col
        ><el-col span="8">
          <el-form-item label="商品编码" prop="productCode">
            <el-input v-model="form.productCode" placeholder="请输入商品编码" />
          </el-form-item>
          <el-form-item label="商品数量" prop="productNum">
            <el-input v-model="form.productNum" placeholder="请输入商品数量" />
          </el-form-item>
          <el-form-item label="商品名称" prop="productName">
            <el-input v-model="form.productName" placeholder="请输入商品名称" />
          </el-form-item>
          <el-form-item label="商品单价" prop="productPricing">
            <el-input
              v-model="form.productPricing"
              placeholder="请输入商品单价"
            />
          </el-form-item>
          <el-form-item label="商品成本" prop="productCost">
            <el-input v-model="form.productCost" placeholder="请输入商品成本" />
          </el-form-item>
          <el-form-item label="结算金额" prop="productSettlment">
            <el-input
              v-model="form.productSettlment"
              placeholder="请输入结算金额"
            />
          </el-form-item>
          <el-form-item label="生产批次" prop="productBatch">
            <el-input
              v-model="form.productBatch"
              placeholder="请输入生产批次"
            />
          </el-form-item>
          <el-form-item label="生产日期" prop="manufactureDate">
            <el-date-picker
              clearable
              v-model="form.manufactureDate"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="请选择生产日期"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="快递公司" prop="expressCompany">
            <el-input
              v-model="form.expressCompany"
              placeholder="请输入快递公司"
            />
          </el-form-item>
          <el-form-item label="快递单号" prop="expressNumber">
            <el-input
              v-model="form.expressNumber"
              placeholder="请输入快递单号"
            />
          </el-form-item>
          <el-form-item label="发货时间" prop="deliveryTime">
            <el-date-picker
              clearable
              v-model="form.deliveryTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="请选择发货时间"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="业务员" prop="salesman">
            <el-input v-model="form.salesman" placeholder="请输入业务员" />
          </el-form-item>
          <el-form-item label="便签|线下备注" prop="offlineNotes">
            <el-input
              v-model="form.offlineNotes"
              placeholder="请输入便签|线下备注"
            />
          </el-form-item>
         
          <el-form-item label="退货取件码" prop="returnExpressPickupCode">
            <el-input
              v-model="form.returnExpressPickupCode"
              placeholder="请输入退货取件码"
            />
          </el-form-item>
          <el-form-item label="退货订单号" prop="returnExpressNumber">
            <el-input
              v-model="form.returnExpressNumber"
              placeholder="请输入退货订单号"
            />
          </el-form-item>
          <el-form-item label="退货时间" prop="returnDate">
            <el-date-picker
              clearable
              v-model="form.returnDate"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="请选择退货时间"
            >
            </el-date-picker>
          </el-form-item> </el-col
        ><el-col span="8">
          <el-form-item label="流程模板ID" prop="flowModelId">
            <el-input
              v-model="form.flowModelId"
              placeholder="请输入流程模板ID"
            />
          </el-form-item>
          <el-form-item label="待退货数量" prop="toReturnNum">
            <el-input
              v-model="form.toReturnNum"
              placeholder="请输入待退货数量"
            />
          </el-form-item>
          <el-form-item label="退货中数量" prop="returningNum">
            <el-input
              v-model="form.returningNum"
              placeholder="请输入退货中数量"
            />
          </el-form-item>
          <el-form-item label="已退货数量" prop="returnedNum">
            <el-input
              v-model="form.returnedNum"
              placeholder="请输入已退货数量"
            />
          </el-form-item>
          <el-form-item label="申请时间" prop="applyDate">
            <el-date-picker
              clearable
              v-model="form.applyDate"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="请选择申请时间"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="签收时间" prop="signedTime">
            <el-date-picker
              clearable
              v-model="form.signedTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="请选择签收时间"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="电话" prop="phone">
            <el-input v-model="form.phone" placeholder="请输入电话" />
          </el-form-item>
          <el-form-item label="收件人" prop="recipient">
            <el-input v-model="form.recipient" placeholder="请输入收件人" />
          </el-form-item>
          <el-form-item label="地址" prop="address">
            <el-input v-model="form.address" placeholder="请输入地址" />
          </el-form-item>
          <el-form-item label="收货省份" prop="receiverState">
            <el-input
              v-model="form.receiverState"
              placeholder="请输入收货省份"
            />
          </el-form-item>
          <el-form-item label="收货市" prop="receiverCity">
            <el-input v-model="form.receiverCity" placeholder="请输入收货市" />
          </el-form-item>
          <el-form-item label="收货区/街道" prop="receiverDistrict">
            <el-input
              v-model="form.receiverDistrict"
              placeholder="请输入收货区/街道"
            />
          </el-form-item>
          <el-form-item label="聚水潭-内部订单号" prop="oid">
            <el-input
              v-model="form.oid"
              placeholder="请输入聚水潭-内部订单号"
            />
          </el-form-item>
          <el-form-item label="原始地址" prop="fullAddress">
            <el-input v-model="form.fullAddress" placeholder="请输入原始地址" />
          </el-form-item>
          <el-form-item label="详细地址" prop="detailAddress">
            <el-input
              v-model="form.detailAddress"
              placeholder="请输入详细地址"
            />
          </el-form-item>
          
          <el-form-item label="支付截图" prop="paymentUrl">
            <el-input v-model="form.paymentUrl" placeholder="请输入支付截图" />
          </el-form-item>
        </el-col>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog> -->

    <!-- 添加或修改样衣申请记录对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="60%"
      append-to-body
      v-if="open"
    >
      <div class="el-dialog-div">
        <el-form ref="form" :model="form" :rules="rules" label-width="100px">
          <el-col :span="10">
            <!-- <el-form-item label="达人信息表ID" prop="sampleTalentInfoId">
              <el-input v-model="form.sampleTalentInfoId" placeholder="达人信息表ID" />
            </el-form-item>
            <el-form-item label="笔记/直播合作ID" prop="sampleTalentCooperateId">
              <el-input v-model="form.sampleTalentCooperateId" placeholder="笔记/直播合作ID" />
            </el-form-item> -->
            <!-- <el-form-item label="模板ID" prop="templateId">
              <el-input v-model="form.templateId" placeholder="模板ID" />
            </el-form-item> -->
            <!-- <el-form-item label="颜色ID" prop="templateSecondryId">
              <el-input v-model="form.templateSecondryId" placeholder="颜色ID" />
            </el-form-item>
            <el-form-item label="尺寸ID" prop="templateSizeId">
              <el-input v-model="form.templateSizeId" placeholder="尺寸ID" />
            </el-form-item>
            <el-form-item label="联系方式ID" prop="contactId">
              <el-input v-model="form.contactId" placeholder="联系方式ID" />
            </el-form-item> -->

            <el-form-item label="合作款式" prop="productNo">
              <!-- <el-input v-model="form.productNo" placeholder="请输入货号" /> -->
              <el-select
                :disabled="to_apply"
                v-model="form.productNo"
                clearable
                filterable
                remote
                :remote-method="getDatas"
                :loading="loading"
                placeholder="请选择合作款式"
              >
                <el-option
                  v-for="item in options"
                  :key="item"
                  :label="item"
                  :value="item"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="颜色属性" prop="colorProperty">
              <!-- <el-input v-model="form.colorProperty" placeholder="请输入颜色属性" :loading="loading"/> -->
              <el-select
                :disabled="to_sumbit"
                @focus="onFocus"
                ref="selectRef"
                v-model="form.colorProperty"
                clearable
                filterable
                remote
                :remote-method="getData"
                placeholder="请选择颜色属性"
              >
                <el-option
                  v-for="item in ColorLike"
                  :key="item"
                  :label="item"
                  :value="item"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="尺寸" prop="productSize">
              <el-select
                :disabled="to_sumbit"
                @focus="onFocus"
                v-model="form.productSize"
                clearable
                filterable
                remote
                :remote-method="getSize"
                placeholder="请选择尺寸"
                @change="testSize"
              >
                <el-option
                  v-for="item in sizeList"
                  :key="item.id"
                  :label="item.size"
                  :value="item.size"
                >
                </el-option>
              </el-select>
              <!-- <el-select v-model="form.size" placeholder="请选择尺寸" clearable>
                <el-option v-for="dict in dict.type.sys_product_size" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select> -->
            </el-form-item>
            <el-form-item label="商品数量" prop="productNum">
              <el-input
                :disabled="to_sumbit"
                v-model="form.productNum"
                placeholder="商品数量"
                type="number"
                oninput="value=value.replace(/^0|[^0-9]/g,'')"
              />
              <el-button type="primary" size="mini" @click="getinventory"
                >查询</el-button
              >
              <span style="color: red">当前库存量：{{ num }}</span>
            </el-form-item>
            <!-- <el-form-item label="卖家备注" prop="remark">
              <el-input v-model="form.remark" placeholder="卖家备注" />
            </el-form-item> -->
            <!-- <el-form-item label="线上订单号" prop="onlineNumber">
              <el-input v-model="form.onlineNumber" placeholder="线上订单号" />
            </el-form-item>
            <el-form-item label="子订单编号" prop="subOrderNumber">
              <el-input v-model="form.subOrderNumber" placeholder="子订单编号" />
            </el-form-item> -->

            <!-- <el-form-item label="申请人" prop="buyerAccount">
              <el-input v-model="form.buyerAccount" placeholder="申请人" />
            </el-form-item> -->

            <!-- <el-form-item label="支付单号" prop="paymentOrderNumber">
              <el-input v-model="form.paymentOrderNumber" placeholder="支付单号" />
            </el-form-item>
            <el-form-item label="付款方式" prop="paymentMethod">
              <el-input v-model="form.paymentMethod" placeholder="付款方式" />
            </el-form-item>
            <el-form-item label="运费" prop="freight">
              <el-input v-model="form.freight" placeholder="运费" />
            </el-form-item>
            <el-form-item label="应付金额" prop="payableAmount">
              <el-input v-model="form.payableAmount" placeholder="应付金额" />
            </el-form-item> -->
            <el-form-item label="快递公司" prop="expressCompany">
              <!-- <el-input v-model="form.expressCompany" placeholder="快递公司" /> -->
              <el-select
                :disabled="to_sumbit"
                v-model="form.expressCompany"
                placeholder="请选择快递公司"
                clearable
                filterable
              >
                <el-option
                  v-for="dict in dict.type.sys_jst_sample_sf"
                  :key="dict.label"
                  :label="dict.label"
                  :value="dict.label"
                />
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="是否归还" prop="isReturn">
              <el-select
                v-model="form.isReturn"
                placeholder="请选择是否归还"
                clearable
                filterable
              >
                <el-option
                  v-for="dict in dict.type.sys_one_zero"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.label"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="归还补充说明" prop="isReturnRemark">
              <el-input
                v-model="form.isReturnRemark"
                placeholder="归还补充说明"
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 12 }"
                :style="{ width: '100%' }"
              />
              
            </el-form-item>
            <el-form-item label="发货备注" prop="innerApplyReason">
              <el-input
                v-model="form.innerApplyReason"
                placeholder="发货备注"
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 12 }"
                :style="{ width: '100%' }"
              />
             
            </el-form-item> -->
          </el-col>
          <el-col :span="1">
            <el-form-item></el-form-item>
          </el-col>
          <el-col :span="13">
            <el-form-item label="收件人" prop="recipient">
              <el-input
                :disabled="to_sumbit"
                v-model="form.recipient"
                placeholder="请输入收件人"
              />
            </el-form-item>
            <el-form-item label="电话" prop="phone">
              <el-input
                :disabled="to_sumbit"
                v-model="form.phone"
                placeholder="请输入电话"
              />
            </el-form-item>

            <el-form-item label="所在区域" prop="">
              <el-row>
                <!-- <el-select v-model="form.receiverState" placeholder="请选择" @change="selectProvimce" style="width:130px">
              <el-option v-for="(item, index) of provincearr" :key="index" :label="item.name"
                :value="item.name"></el-option>
            </el-select>
            <el-select v-model="form.receiverCity" placeholder="请选择" @change="selectcity" style="width:130px">
              <el-option v-for="(item, index) of cityarr" :key="index" :label="item.name" :value="item.name"></el-option>
            </el-select>
            <el-select placeholder="请选择" v-model="form.receiverDistrict" style="width:150px">
              <el-option v-for="(item, index) of regionarr" :key="index" :label="item.name"
                :value="item.name"></el-option>
            </el-select> -->
                <el-select
                  :disabled="to_sumbit"
                  v-model="form.receiverState"
                  clearable
                  placeholder="省"
                  @change="seletekey($event, 'province')"
                  style="width: 130px"
                >
                  <el-option
                    v-for="(val, key) in provinces"
                    :key="key"
                    :label="val"
                    :value="val"
                  />
                </el-select>
                <el-select
                  :disabled="to_sumbit"
                  v-model="form.receiverCity"
                  clearable
                  placeholder="市"
                  @change="seletekey($event, 'city')"
                  style="width: 130px"
                >
                  <el-option
                    v-for="(val, key) in citys"
                    :key="key"
                    :label="val"
                    :value="val"
                  />
                </el-select>
                <el-select
                  :disabled="to_sumbit"
                  v-model="form.receiverDistrict"
                  clearable
                  placeholder="县区"
                  @change="seletekey($event, 'area')"
                  style="width: 135px"
                  filterable
                  allow-create
                >
                  <el-option
                    v-for="(val, key) in areas"
                    :key="key"
                    :label="val"
                    :value="val"
                  />
                </el-select>
              </el-row>
            </el-form-item>
            <el-form-item label="收件人地址" prop="address">
              <el-input
                :disabled="to_sumbit"
                v-model="form.address"
                placeholder="请输入收件人地址"
                style="width: 300px"
              />
            </el-form-item>
            <el-form-item label="文本粘贴" prop="">
              <el-input
                v-model="demo"
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 10 }"
                placeholder="省市区地址、姓名、电话11位用空格分开!!"
                style="width: 350px"
              ></el-input>
              <el-button type="primary" size="mini" @click="addText"
                >识别</el-button
              >
              <!-- <el-input v-model="sampleTalentPay.platform" placeholder="请输入平台名称" /> -->
            </el-form-item>
            <!-- <el-form-item label="款式主图" prop="styleMainImage">
              <image-upload v-model="form.styleMainImage" />
            </el-form-item> -->
            <!-- <el-form-item label="内部订单号" prop="bindingSoid">
              <el-input v-model="form.bindingSoid" placeholder="内部订单号" />
            </el-form-item> -->

            <!-- <el-form-item label="商品名称" prop="productName">
              <el-input v-model="form.productName" placeholder="商品名称" />
            </el-form-item>
            <el-form-item label="商品单价" prop="productPricing">
              <el-input v-model="form.productPricing" placeholder="商品单价" />
            </el-form-item>
            <el-form-item label="商品成本" prop="productCost">
              <el-input v-model="form.productCost" placeholder="商品成本" />
            </el-form-item>
            <el-form-item label="结算金额" prop="productSettlment">
              <el-input v-model="form.productSettlment" placeholder="结算金额" />
            </el-form-item>
            <el-form-item label="生产批次" prop="productBatch">
              <el-input v-model="form.productBatch" placeholder="生产批次" />
            </el-form-item>
            <el-form-item label="生产日期" prop="manufactureDate">
              <el-date-picker clearable v-model="form.manufactureDate" type="date" value-format="yyyy-MM-dd"
                placeholder="请选择生产日期">
              </el-date-picker>
            </el-form-item> -->

            <!-- <el-form-item label="快递单号" prop="expressNumber">
              <el-input v-model="form.expressNumber" placeholder="快递单号" />
            </el-form-item>
            <el-form-item label="发货时间" prop="deliveryTime">
              <el-date-picker clearable v-model="form.deliveryTime" type="date" value-format="yyyy-MM-dd"
                placeholder="请选择发货时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="业务员" prop="salesman">
              <el-input v-model="form.salesman" placeholder="业务员" />
            </el-form-item> -->

            <!-- <el-form-item label="逻辑删除;0=未删除；1=已删除" prop="isDelete">
          <el-input v-model="form.isDelete" placeholder="逻辑删除;0=未删除；1=已删除" />
        </el-form-item> -->
          </el-col>
          <!-- <el-col :span="1">
            <el-form-item></el-form-item>
          </el-col>
          <el-col :span="7"> </el-col> -->

          <!-- <el-form-item label="便签|线下备注" prop="offlineNotes">
              <el-input v-model="form.offlineNotes" placeholder="便签|线下备注" />
            </el-form-item>
            <el-form-item label="固话" prop="fixedLine">
              <el-input v-model="form.fixedLine" placeholder="固话" />
            </el-form-item>
            <el-form-item label="邮编" prop="zipCode">
              <el-input v-model="form.zipCode" placeholder="邮编" />
            </el-form-item>
            <el-form-item label="退货电话" prop="returnPhone">
              <el-input v-model="form.returnPhone" placeholder="退货电话" />
            </el-form-item>
            <el-form-item label="退货收件人" prop="returnRecipient">
              <el-input v-model="form.returnRecipient" placeholder="退货收件人" />
            </el-form-item>
            <el-form-item label="退货收件人地址" prop="returnAddress">
              <el-input v-model="form.returnAddress" placeholder="退货收件人地址" />
            </el-form-item>
            <el-form-item label="退货联系方式" prop="returnContactId">
              <el-input v-model="form.returnContactId" placeholder="退货联系方式" />
            </el-form-item>
            <el-form-item label="退货取件码" prop="returnExpressPickupCode">
              <el-input v-model="form.returnExpressPickupCode" placeholder="退货取件码" />
            </el-form-item>
            <el-form-item label="退货订单号" prop="returnExpressNumber">
              <el-input v-model="form.returnExpressNumber" placeholder="退货订单号" />
            </el-form-item>
            <el-form-item label="退货时间" prop="returnDate">
              <el-date-picker clearable v-model="form.returnDate" type="date" value-format="yyyy-MM-dd"
                placeholder="请选择退货时间">
              </el-date-picker>
            </el-form-item> -->
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { submitApplyByApplyIdList } from "@/api/internal/internalOrder";
import {
  listApply,
  getApply,
  delApply,
  addApply,
  updateApply,
} from "@/api/internal/apply";
import {
  listSecondry,
  getSecondry,
  delSecondry,
  addSecondry,
  updateSecondry,
  getInfoByName,
  productNoColorLike,
  listAll,
} from "@/api/product/secondry";
import {
  listTemplate,
  getTemplate,
  delTemplate,
  addTemplate,
  updateTemplate,
  addTemplateAndSecondry,
  addProNoColorSize,
  productNoLike,
} from "@/api/product/template";
import { inventory } from "@/api/sample/sample";
import AddressParse from "address-parse";
import { pcaa } from "area-data";
import { getInfo } from "@/api/login.js";
export default {
  name: "Apply",
  dicts: [
    "sys_product_qudao",
    "sys_one_zero",
    "sys_product_size",
    "sys_sample_sf",
    "sys_jst_sample_sf",
  ],
  props: {
    templateId: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      to_apply: false,
      //待提交申请禁用
      to_sumbit: false,
      applyname: "",

      num: "",

      //文本粘贴
      demo: "",
      //省市区
      pcaaData: pcaa,
      // 区域数据
      provinces: pcaa["86"],
      citys: [],
      areas: [],

      //模糊匹配
      sizeList: [],
      ColorLike: [],
      options: [], // 选项，从后端传递过来
      //搜索栏展示和收起
      isOpen: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 内购申请记录表格数据
      applyList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        internalPurchaseContactId: null,
        templateId: null,
        onlineNumber: null,
        subOrderNumber: null,
        buyerAccount: null,
        paymentOrderNumber: null,
        paymentMethod: null,
        freight: null,
        payableAmount: null,
        fixedLine: null,
        zipCode: null,
        styleMainImage: null,
        productCode: null,
        productNum: null,
        productName: null,
        productPricing: null,
        productCost: null,
        productSettlment: null,
        productBatch: null,
        manufactureDate: null,
        expressCompany: null,
        expressNumber: null,
        deliveryTime: null,
        salesman: null,
        offlineNotes: null,
        applyStatus: null,
        isDelete: null,
        returnContactId: null,
        returnExpressPickupCode: null,
        returnExpressNumber: null,
        returnDate: null,
        flowModelId: null,
        toReturnNum: null,
        returningNum: null,
        returnedNum: null,
        applyDate: null,
        signedTime: null,
        phone: null,
        recipient: null,
        address: null,
        receiverState: null,
        receiverCity: null,
        receiverDistrict: null,
        oid: null,
        fullAddress: null,
        detailAddress: null,
        innerApplyReason: null,
        bindingSoid: null,
        isReturnRemark: null,
        paymentUrl: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        internalPurchaseContactId: [
          {
            required: true,
            message: "内购通信录表ID不能为空",
            trigger: "blur",
          },
        ],
        phone: [{ required: true, message: "电话不能为空", trigger: "blur" }],
      },
    };
  },
  created() {
    this.getroles();
    // this.getList();
  },
  watch: {
    // 监听复选框配置列所有的变化
    templateId: {
      handler: function (newnew, oldold) {
        console.log("newnew", newnew);
        if (newnew) {
          this.queryParams.templateId = newnew;
          this.getList();
        } else {
          this.applyList = [];
        }
        // this.showColumn = newnew;
        // // 这里需要让表格重新绘制一下，否则会产生固定列错位的情况
        // this.$nextTick(() => {
        //   this.$refs.BaseTable.doLayout();
        // });
      },
      deep: true,
      immediate: true,
    },
  },
  filters: {
    state1(string) {
      if (string == "exchange") {
        return "换货";
      }
      if (string == "return") {
        return "退货";
      }
      if (string == "outofstock") {
        return "缺货";
      }
      // if (int == 2) { return "审批通过" };
    },
    /***
     * 换货:exchange
退货:return
缺货:
    一级二级增加售后状态
字段：applyStatus,状态值有3
1、待认领达人 -可以修改产品信息 status:to_match
2、待提交售后  --可修改达人信息，不能修改产品信息status:to_apply
3、已售后  --不可修改任意信息status:applyed 
    ** */
    state2(string) {
      if (string == "to_exchange") {
        return "待换货";
      }
      if (string == "to_apply") {
        return "待提交申请";
      }
      if (string == "dingding_approval") {
        return "待钉钉审核";
      }
      if (string == "dingding_approved") {
        return "已审核";
      }
      if (string == "supervisor_approval") {
        return "待审核";
      }
      if (string == "product_supervisor") {
        return "待产品中心经理审核";
      }
      if (string == "manage_approval") {
        return "待经理审核";
      }
      if (string == "commodity_approval") {
        return "待商品部审核";
      }
      if (string == "shipped_ready") {
        return "待发货";
      }
      if (string == "shipped") {
        return "已发货";
      }
      if (string == "to_signed") {
        return "待签收";
      }
      if (string == "signed") {
        return "已签收";
      }
      if (string == "to_returned") {
        return "待退货";
      }
      if (string == "returning") {
        return "退货中";
      }
      if (string == "returned") {
        return "已退样";
      }
      if (string == "part_returned") {
        return "部分退样";
      }
      if (string == "not_return") {
        return "不归还";
      }
      if (string == "cancel_return") {
        return "未收到";
      }
      if (string == "end") {
        return "结束";
      }
      if (string == "canceled") {
        return "已取消";
      }
      // if (int == 2) { return "审批通过" };
    },
  },
  methods: {
    getroles() {
      // var userId = null
      getInfo().then((res) => {
        console.log(JSON.stringify(res));
        this.applyname = res.user.dept.deptName + "-" + res.user.nickName;
        console.log(JSON.stringify(this.applyname));
      });
    },
    addText() {
      if (!this.demo) {
        this.$modal.msgError("请输入内容");
        return;
      }
      let address = this.demo.replace(/\s+/g, " ");
      const result = AddressParse.parse(address);

      this.form.phone = result[0].mobile ? result[0].mobile : "";
      this.form.recipient = result[0].name ? result[0].name : "";
      this.form.receiverState = result[0].province ? result[0].province : "";
      this.form.receiverCity = result[0].city ? result[0].city : "";
      this.form.receiverDistrict = result[0].area ? result[0].area : "";
      this.form.address = result[0].details;
      this.seletekey(this.form.receiverState, "province");
      this.seletekey(this.form.receiverCity, "city");
      this.seletekey(this.form.receiverDistrict, "area");
      // axios({
      //   method: "post",
      //   url: "https://wangzc.wang/smAddress",
      //   // url: "http://47.97.123.182:1399/smAddress",
      //   data: {
      //     address: address,
      //   },
      // }).then((res) => {
      //   // console.log(JSON.stringify(res.data));
      //   this.form.phone = res.data.phone ? res.data.phone : "";
      //   this.form.recipient = res.data.name ? res.data.name : "";
      //   this.form.receiverState = res.data.province ? res.data.province : "";
      //   this.form.receiverCity = res.data.city ? res.data.city : "";
      //   this.form.receiverDistrict = res.data.county ? res.data.county : "";
      //   this.form.address = res.data.street
      //     ? res.data.street + res.data.address
      //     : res.data.address;
      //   this.seletekey(this.form.receiverState, "province");
      //   this.seletekey(this.form.receiverCity, "city");
      //   this.seletekey(this.form.receiverDistrict, "area");
      // });
    },
    seletekey(e, type) {
      if (e) {
        switch (type) {
          case "province":
            Object.keys(this.provinces).filter((item) => {
              if (this.provinces[item] === e) {
                this.citys = this.pcaaData[item];
              }
            });
            break;
          case "city":
            Object.keys(this.citys).filter((item) => {
              if (this.citys[item] === e) {
                this.areas = this.pcaaData[item];
              }
            });
            break;
          case "area":
            this.form.receiverDistrict = e;
            this.$forceUpdate();
            break;
        }
      }
    },
    //获取库存
    getinventory() {
      inventory({
        productNo: this.form.productNo,
        colorProperity: this.form.colorProperty,
        size: this.form.productSize,
      }).then((res) => {
        // console.log(JSON.stringify(res.data));
        if (res.code == 200) {
          if (res.data.length > 0) {
            this.num = res.data[0].publicCanUseNum;
            this.$forceUpdate();
          } else {
            this.$modal.msgError("该商品编码聚水潭不存在，请核对。");
          }
        }
        // else {
        //   this.$modal.msgError(res.msg)
        // }
      });
    },
    //修改对话框
    //添加颜色列表获得焦点
    onFocus() {
      this.getData();

      this.getSize();
      // if (!this.form.colorProperty) {
      //     this.$selectRef.value.blur() //就是这一句，
      // }
    },
    testSize() {
      this.getinventory();
    },

    //修改对话框
    /* 获取颜色列表 */
    getSize(key) {
      console.log(JSON.stringify(key));
      // this.loading = true;
      // return
      listAll({
        productNo: this.form.productNo,
        colorProperty: this.form.colorProperty,
      }).then((res) => {
        // this.loading = false;
        this.sizeList = res;
        console.log(JSON.stringify(res));
      });
    },
    /* 获取颜色列表 */
    getData(key) {
      console.log(JSON.stringify(key));
      // this.loading = true;
      // return
      productNoColorLike({ productNo: this.form.productNo, color: key }).then(
        (res) => {
          // this.loading = false;
          this.ColorLike = res.data;
          console.log(JSON.stringify(this.ColorLike));
        }
      );
    },

    /* 获取货号列表 */
    getDatas(key) {
      console.log(JSON.stringify(key));
      this.loading = true;
      // return
      productNoLike(key).then((res) => {
        this.loading = false;
        this.options = res.data;
        console.log(JSON.stringify(this.options));
      });
    },
    //点击某一行
    t(row, column, cell, event) {
      console.log(row, column, cell, event);

      this.handleUpdate(row);
    },
    //搜索栏展示与收起
    shouqi() {
      // console.log(1);
      this.isOpen = !this.isOpen;
    },
    /** 查询内购申请记录列表 */
    getList() {
      this.loading = true;
      listApply(this.queryParams).then((response) => {
        this.applyList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        internalPurchaseContactId: null,
        templateId: null,
        remark: null,
        onlineNumber: null,
        subOrderNumber: null,
        buyerAccount: null,
        paymentOrderNumber: null,
        paymentMethod: null,
        freight: null,
        payableAmount: null,
        fixedLine: null,
        zipCode: null,
        styleMainImage: null,
        productCode: null,
        productNum: null,
        productName: null,
        productPricing: null,
        productCost: null,
        productSettlment: null,
        productBatch: null,
        manufactureDate: null,
        expressCompany: null,
        expressNumber: null,
        deliveryTime: null,
        salesman: null,
        offlineNotes: null,
        applyStatus: null,
        isDelete: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        returnContactId: null,
        returnExpressPickupCode: null,
        returnExpressNumber: null,
        returnDate: null,
        flowModelId: null,
        toReturnNum: null,
        returningNum: null,
        returnedNum: null,
        applyDate: null,
        signedTime: null,
        phone: null,
        recipient: null,
        address: null,
        receiverState: null,
        receiverCity: null,
        receiverDistrict: null,
        oid: null,
        fullAddress: null,
        detailAddress: null,
        innerApplyReason: null,
        bindingSoid: null,
        isReturnRemark: null,
        paymentUrl: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加内购申请记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getApply(id).then((response) => {
        this.form = response.data;
        this.to_apply = true;
        if (response.data.applyStatus !== "to_apply") {
          //
          this.to_sumbit = true;
        } else {
          // console.log(5555454);
          this.to_sumbit = false;
        }

        if (response.data.buyerAccount == this.applyname) {
          if (response.data.applyStatus == "dingding_approval") {
            this.open = false;
            this.$modal.msgError("订单处于 “待钉钉审核”状态，暂不可修改。");
            return;
          } else {
            this.open = true;
          }
        } else {
          this.open = false;
          this.$modal.msgError("请选择本人申请记录信息！");
          return;
        }
        this.title = "修改内购申请记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateApply(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.to_apply = false;
              this.open = false;
              this.getList();
            });
          } else {
            addApply(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
          this.demo = "";
        }
      });
    },
    // 打开加载层
    openLoading1() {
      this.$modal.loading("正在申请，请稍候！");
    },
    handleApply(row) {
      const ids = row.id || this.ids;
      this.openLoading1();
      submitApplyByApplyIdList(ids).then((response) => {
        this.$modal.closeLoading();
        if (response.code == 200) {
          this.getList();
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除内购申请记录编号为"' + ids + '"的数据项？')
        .then(function () {
          return delApply(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "product/apply/export",
        {
          ...this.queryParams,
        },
        `apply_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style lang="scss" scoped>
.el-dialog-div {
  height: 50vh;
  overflow-x: hidden;
}
</style>